package com.ylxn.sqlSession;

import com.ylxn.config.XMLConfigBuilder;
import com.ylxn.pojo.Configuration;

import java.io.InputStream;

public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream inputStream) throws Exception {
        
        //1,使用dom4j解析配置文件，将解析出来的配置文件封装到Configuration中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);
        //2，创建SqlsessionFactory（工厂类）对象，生产sqlSession:会话对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}
